package com.cxb.serviceDriverUser.service;

import com.cxb.internalcommon.dto.DriverUser;
import com.cxb.internalcommon.dto.DriverUserWorkStatus;
import com.cxb.internalcommon.dto.ResponseResult;
import com.cxb.serviceDriverUser.mapper.DriverUserMapper;
import com.cxb.serviceDriverUser.mapper.DriverUserWorkStatusMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.java2d.pipe.RegionSpanIterator;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author 陈晓波
 * @since 2024-07-29
 */
@Service
public class DriverUserWorkStatusService {

    @Autowired
    private DriverUserWorkStatusMapper driverUserWorkStatusMapper;

    /**
     * 修改司机工作状态
     * @param driverId
     * @param workStatus
     * @return
     */
    public ResponseResult changeWorkStatus(Long driverId,Integer workStatus){

        Map<String,Object> queryMap = new HashMap<>();
        queryMap.put("driver_id",driverId);
        List<DriverUserWorkStatus> driverUserWorkStatuses = driverUserWorkStatusMapper.selectByMap(queryMap);
        DriverUserWorkStatus driverUserWorkStatus = driverUserWorkStatuses.get(0);
        //更新司机状态
        driverUserWorkStatus.setWorkStatus(workStatus);
        driverUserWorkStatusMapper.updateById(driverUserWorkStatus);
        return ResponseResult.success("");
    }

}
